package cn.le.api;

import cn.le.dto.ProductDTO;
import cn.le.service.ProductService;
import cn.le.util.ResponseFactory;
import cn.le.vo.ResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(value = "产品功能")
@RestController
@RequestMapping(value = "/api/product")
public class ProductApi {

    @Autowired
    private ProductService productService;

    @ApiOperation(value = "新增产品",notes = "新增产品")
    @RequestMapping(value = "add",method = RequestMethod.POST)
    public ResponseVO add(@RequestBody @Valid ProductDTO dto){
        productService.add(dto);
        return ResponseFactory.ok("添加成功");
    }



}
